﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
using BusinessLogic;
using System.Data;

namespace CarService
{
    public partial class AccesssoryPrice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ucPaging.PageChange += new Manager.Controls.ucPaging.PagingHandler(Load_Data);
            Load_Info();
            if (!Page.IsPostBack)
            {
                ucPaging.PageSize = 30;
                ucPaging.PageDisplay = 5;
                Load_Data();
            }
        }

        private void Load_Info()
        {
            SettingInfo settingInfo = SettingData.SelectBySiteID(Config.Global.Settings.SiteID);
            Page.Title = settingInfo.SiteName + " - Bảng giá Linh kiện";
            Page.MetaDescription = settingInfo.SiteDescription;
            Page.MetaKeywords = settingInfo.SiteKeyword;
        }

        private void Load_Data()
        {
            int totalRecord = 0;
            AccessoryBusiness accessoryBusiness = new AccessoryBusiness();
            DataTable dtbAccessory = accessoryBusiness.Search("", ucPaging.CurrentPage, ucPaging.PageSize, ref totalRecord);
            ucPaging.TotalRecord = totalRecord;
            ucPaging.Visible = ucPaging.TotalPage > 1;

            if ((dtbAccessory != null) && (dtbAccessory.Rows.Count > 0))
            {
                rptAccessoryPrice.DataSource = dtbAccessory;
                rptAccessoryPrice.DataBind();
            }
        }
    }
}